package com.songlanyun.modules.exception;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 配置异常
 */
public enum ConfigException implements IntegerEnum<Integer> {

    CONFIG_NOT_EXIST(70001, "配置不存在"),
    SALE_CONFIG_NOT_EXIST(70002, "平台交易配置必须先设置"),

    PERSONAL_DATA_NOT_EXIST(70003, "个人资料不存在"),
    MOBILE_REGISTER(70004, "该手机号已登记，24小时内会有客服联系你，请保持电话通畅"),
    UP_TO_6_SETS_OF_DONATION_RULES_CAN_BE_SET(70005, "最多可设置6组捐款规则"),
    THE_DONATION_RULE_CANNOT_BE_NULL(70006, "捐赠规则不能为空"),
    THE_POINTS_EXCHANGE_CONFIGURATION_DOES_NOT_EXIST(70007, "积分兑换配置不存在"),
    CONFIG_VALUE_NOT_EXIST(70008, "配置值不能为空"),
    POINT_NOT_FULL(80002, "账户积分不足！"),
    RECHARGE_HAVE_DONE(80003, "转入订单已处理，请勿重复操作！"),
    RECHARGE_ACCOUNT_IS_NOT_EXSIT(80004, "转入账户不存在！"),
    WITHDRAWAL_BSID_IS_NOT_EXSIT(80005, "提现订单不存在！"),
    WITHDRAWAL_UID_IS_NOT_SAME(80006, "提现回调的用户uid与本地订单uid不一致！"),
    WITHDRAWAL_AMOUNT_IS_NOT_SAME(80007, "提现回调的积分数与本地订单积分数不一致！"),


    ;


    private Integer code;

    private String msg;

    ConfigException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    @JsonCreator
    public static ConfigException getByCode(int code) {
        for (ConfigException value : ConfigException.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
